using System;
using System.Xml;
using System.Data;
using System.Data.SqlClient; 

/// <summary>
/// Summary description for SqlServerTransaction
/// </summary>
public partial class SqlServerProvider
{
    #region	 ExecuteNonQuery
    public int ExecuteNonQuery()
    {
        sqlCommand = new SqlCommand();
        sqlCommand.CommandText = commandText;
        sqlCommand.Connection = sqlConnection;
        sqlCommand.CommandType = commandType;
        if(ParameterCollection.Length>0)
            AddParameters(sqlCommand);

        int rows = sqlCommand.ExecuteNonQuery();
        sqlCommand.Dispose();
        return rows;

    }
     
    #endregion

    #region ExecuteScalar

    public object ExecuteScalar( )
    {
        sqlCommand = new SqlCommand();
        sqlCommand.CommandText = commandText;
        sqlCommand.Connection = sqlConnection;
        sqlCommand.CommandType = commandType;

        if (ParameterCollection!=null)
            AddParameters(sqlCommand);

        object obj = sqlCommand.ExecuteScalar();
        sqlCommand.Dispose();
        return obj;
    }

     
    #endregion

    public XmlReader ExecuteXmlReader()
    {
        XmlReader xmlReader = null;
        errorMessage = "";
       
        try
        {
            OpenConnection();
            sqlCommand = new SqlCommand();
            sqlCommand.CommandText = commandText;
            sqlCommand.Connection = sqlConnection;
            sqlCommand.CommandType = commandType;
            xmlReader = sqlCommand.ExecuteXmlReader();
            CloseConnection();
        }
        catch (SqlException sql)
        {
            errorCode = sql.Number;
            errorMessage = sql.Message;
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return xmlReader;
    }
}

